<?php
 	header('Access-Control-Allow-Origin:*'); 
 	$MsgID = null;
 	$uid = null;
	if(isset($_REQUEST['MsgID'])){
		$MsgID = $_REQUEST['MsgID'];
	}

	if($MsgID == null){
		$MsgID = 'init';
	}
	if(isset($_REQUEST['uid'])){
		$uid = $_REQUEST['uid'];
	}

	$backInfo = null;

	if($MsgID == 'init'){
		$backInfo = array('MsgID' => $MsgID, 'score'=>1000);
	}
	else if($MsgID == 'deal'){
		$pokerArr = array();
		$echoArr = array();
		$i = 1;
		while ($i <= 10) {
		   $randNum = rand(0,51);
			while(in_array($randNum, $pokerArr)) {
				$randNum = rand(0, 51);
			}

			array_push($pokerArr, $randNum);
			$echoArr[$i] = $randNum;
		   $i++;
		}

		//$echoArr = new array('1'=>0,'2'=>13,'3'=>34,'4'=>45,'5'=>3,'6'=>4,'7'=>7,'8'=>35,'9'=>20,'10'=>33);
		$backInfo = array('MsgID' => $MsgID, 'poker' => $echoArr, 'score'=>1200);
	}
	else if($MsgID == 'double'){
		$pokerArr = array();
		$echoArr = array();
		$i = 1;
		while ($i <= 5) {
		   $randNum = rand(0,51);
			while(in_array($randNum, $pokerArr)) {
				$randNum = rand(0, 51);
			}

			array_push($pokerArr, $randNum);
			$echoArr[$i] = $randNum;
		   $i++;
		}

		$backInfo = array('MsgID' => $MsgID, 'poker' => $echoArr, 'score'=>1400);
	}
	else if($MsgID == 'daily'){
		$backInfo = array('MsgID' => $MsgID, 'score'=>1600, 'hasReward'=>'false');
	}
	$backInfo['uid'] = $uid;

	echo json_encode($backInfo);
?>